home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Fields_rotate.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  4.8 KB  |  189 lines

  1. /*
  2. ** $VER: Fields_rotate.ieb 1.11, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 1/2 1997 Stockholm/Sweden
  6. **
  7. ** Individually rotate small fields in primary image.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   Xfield=64 ; Yfield=64 ; Angle=45
  42.  
  43.   if command ~= '' then parse var command Xfield Yfield Angle '#'CalcType
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Fields Rotate" " OK | Cancel "',
  48.   ' INTEGER,"Field size width (X)",2,1024,'Xfield',SLIDER',
  49.   ' INTEGER,"Field size height (Y)",2,1024,'Yfield',SLIDER',
  50.   ' INTEGER,"Rotation angle",-3600,3600,'Angle',SLIDER'
  51.  
  52.   if command = '' then do
  53.     form = form||' CYCLE,"Type:","Best|Fast",0'
  54.  
  55.     form
  56.     parse var result ok Xfield Yfield Angle CalcType .
  57.     if ok = 0 then return '<ERROR>'
  58.  
  59.     if CalcType=0 then CalcType='BEST'
  60.     else CalcType = 'FAST'
  61.   end
  62.   else do
  63.     form
  64.     parse var result ok Xfield Yfield Angle .
  65.     if ok = 0 then return '<ERROR>'
  66.  
  67.     CalcType = 'none'
  68.   end
  69.  
  70.   back = Xfield Yfield Angle '#'CalcType
  71. return back
  72.  
  73. /* Required "Process_image" procedure  ------------------------------- */
  74.  
  75. process_image:
  76.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  77.   parse var options Xfield Yfield Angle '#'CalcType .
  78.  
  79.   'OPEN' '"'src_image'"' '24'
  80.   if (RC ~= 0) then do
  81.     'IE_TO_FRONT'
  82.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  83.     return '<ERROR>'
  84.   end
  85.   else LoadImage = result
  86.  
  87.   'PROJECT_INFO' LoadImage 'WIDTH'  /* image width */
  88.   IW = RESULT
  89.   'PROJECT_INFO' LoadImage 'HEIGHT' /* image height */
  90.   IH = RESULT
  91.  
  92.   do until ((Angle < 360)&(Angle >= 0))
  93.     if Angle > 359 then Angle = Angle - 360
  94.     if Angle < 0 then Angle = Angle + 360
  95.   end
  96.  
  97.   'BRIGHTNESS' LoadImage '-255'
  98.   BackImage = Result
  99.  
  100.   do y = 1 to trunc(IH/Yfield)+1
  101.     do x = 1 to trunc(Xfield)+1
  102.  
  103.       CropX = trunc((x-1)*Xfield)
  104.       CropY = trunc((y-1)*Yfield)
  105.       CropXX = trunc(x*Xfield)-1
  106.       CropYY = trunc(y*Yfield)-1
  107.  
  108.       if CropXX >= IW then CropXX = IW-1
  109.       if CropYY >= IH then CropYY = IH-1
  110.       if CropXX <= CropX then leave
  111.       if CropYY <= CropY then leave
  112.  
  113.       'CROP' LoadImage CropX CropY CropXX CropYY
  114.       CropImage = Result
  115.  
  116.       'PROJECT_INFO' CropImage 'WIDTH'  /* crop image width */
  117.       CIW = RESULT
  118.       'PROJECT_INFO' CropImage 'HEIGHT' /* crop image height */
  119.       CIH = RESULT
  120.  
  121.       if (CIW ~= Xfield)|(CIH ~= Yfield) then do
  122.         'RESIZE' CropImage Xfield Yfield
  123.         NewCropImage = RESULT
  124.         'CLOSE' CropImage
  125.         CropImage = NewCropImage
  126.       end
  127.  
  128.       if Angle ~= 0 then do
  129.         'ROTATE' CropImage Angle CalcType
  130.         RotImage = Result
  131.         'CLOSE' CropImage
  132.       end
  133.       else RotImage = CropImage
  134.  
  135.       if (Angle ~= 0)|(Angle ~= 90)|(Angle ~= 180)|(Angle ~= 270) then do
  136.         'RESIZE' RotImage Xfield Yfield 'CENTER'
  137.         NewRotImage = RESULT
  138.         'CLOSE' RotImage
  139.         RotImage = NewRotImage
  140.       end
  141.  
  142.       'MARK' RotImage 'PRIMARY'
  143.       'MARK' BackImage 'SECONDARY'
  144.  
  145.       'COMPOSITE' CropX CropY 'MIX' 100
  146.       NewBackImage = Result
  147.       'CLOSE' BackImage
  148.       BackImage = NewBackImage
  149.       'CLOSE' RotImage
  150.  
  151.     end /* Xfield */
  152.   end /* Yfield */
  153.  
  154.   'CLOSE' LoadImage
  155.   OutputImage = BackImage
  156.  
  157.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  158.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  159.   if (RC ~= 0) then do
  160.     'IE_TO_FRONT'
  161.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  162.     return '<ERROR>'
  163.   end
  164.   'CLOSE' OutputImage
  165.  
  166.   back = 'OK'
  167. return back
  168.  
  169. /* Internal procedures  ---------------------------------------------- */
  170.  
  171. /*******************************************************************/
  172. /* This is where control goes when an error code is returned by IE */
  173. /* It puts up a message saying what happened and on which line     */
  174. /*******************************************************************/
  175.  
  176. error:
  177. if RC=5 then do
  178.     IE_TO_FRONT
  179.     LAST_ERROR
  180.     'REQUEST "'||RESULT||'"'
  181. end
  182. else do
  183.     IE_TO_FRONT
  184.     LAST_ERROR
  185.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  186. end
  187.  
  188. return '<ERROR>'
  189.